home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
language
/
xlisp_21.zoo
/
xl-cl001.fix
< prev
next >
Wrap
Internet Message Format
|
1990-02-28
|
41KB
From sce!mitel!uunet!zephyr.ens.tek.com!tekcrl!tekgvs!toma Sat Sep 16 08:20:18 EDT 1989
Article: 1 of comp.lang.lisp.x
Path: cognos!sce!mitel!uunet!zephyr.ens.tek.com!tekcrl!tekgvs!toma
From: toma@tekgvs.LABS.TEK.COM (Tom Almy)
Newsgroups: comp.lang.lisp.x
Subject: XLISP 2.0 BUG(?)
Message-ID: <5911@tekgvs.LABS.TEK.COM>
Date: 11 Sep 89 14:34:11 GMT
Reply-To: toma@tekgvs.LABS.TEK.COM (Tom Almy)
Organization: Tektronix, Inc., Beaverton, OR.
Lines: 22
Part of my effort to make xlisp more compatible with Common Lisp:
Problem: Functions which take the :end keyword argument do not allow NIL
to mean "end of list" as in Common Lisp.
Example: (string-downcase "ABC DEF" :start 4 :end NIL) gives an error.
Fix: in function getbounds() in file xlstr.c, change
if (xlgkfixnum(ekey,&arg)) {
*pend = (int)getfixnum(arg);
to
if (xlgetkeyarg(ekey, &arg) && arg != NIL) {
if (!fixp(arg)) xlbadtype(arg);
*pend = (int)getfixnum(arg);
Tom Almy
toma@tekgvs.labs.tek.com
Standard Disclaimers Apply
From sce!mitel!uunet!zephyr.ens.tek.com!tekcrl!tekgvs!toma Sat Sep 16 08:20:26 EDT 1989
Article: 2 of comp.lang.lisp.x
Path: cognos!sce!mitel!uunet!zephyr.ens.tek.com!tekcrl!tekgvs!toma
From: toma@tekgvs.LABS.TEK.COM (Tom Almy)
Newsgroups: comp.lang.lisp.x
Subject: XLISP 2.0 Modifications (1 of 2)
Message-ID: <5918@tekgvs.LABS.TEK.COM>
Date: 11 Sep 89 22:25:11 GMT
Reply-To: toma@tekgvs.LABS.TEK.COM (Tom Almy)
Organization: Tektronix, Inc., Beaverton, OR.
Lines: 393
I have recently been adding a few Common Lisp functions to XLISP 2.0, and
makeing some existing functions more Common-Lisp compatible (particularly
in making functions that are supposed to take sequence arguments (in XLISP
that would be lists, arrays, or strings) actually take them.
These changes produce the following consequences:
1. Functions with names starting with "STRING" will accept a symbol as
the string argument. The symbols printname string is used.
2. STRCAT is eliminated (a macro is placed in init.lsp for backwards
compatibility). The replacement function is CONCATENATE which will
concatenate sequences of any type(s) into a result sequence of any
type. It is used: (CONCATENATE <type> <seq1> [<seq2> ...]) where
type is the result type, one of CONS ARRAY or STRING.
3. AREF will work on strings as well as arrays.
4. SUBSEQ REVERSE REMOVE... DELETE... take sequence arguments rather
than just list arguments.
5. REMOVE... and DELETE... accept :start and :end keyword arguments.
6. Added function (ELT <seq> <index>) which combines the functionality
of AREF and NTH.
7. Added function (MAP <type> <fcn> <seq1> [<seq2> ...]) a mapping
function over sequences. The resulting sequence is of type <type>,
which is one of CONS ARRAY STRING or NIL (meaning no, or NIL, result).
8. Added functions POSITION-IF, FIND-IF, and COUNT-IF, which work
analogously to REMOVE-IF, but return the position of the first match,
the first match, and number of matches, respectively.
9. Added function (SEARCH <seq1> <seq2> &key :test :test-not :start1
:end1 :start2 :end2) which returns the index of the first occurance
of seq1 in seq2. For example (search #(a b c) '(a b a b c d)) returns
2.
10. Added function (COERCE <expr> <type>) which can coerce between
sequence types and in a limited basis to characters or floating point
numbers.
This is the first of two parts. The final line in this file is "This is
the end of part 1."
Tom Almy
September 11, 1989
toma@tekgvs.labs.tek.com
Standard Disclaimers Apply
***************************************
The first change reduces the amount of code.
In xlsubr.c, add the following definition:
/* xlbadtype - report a "bad argument type" error */
LVAL xlbadtype(arg)
LVAL arg;
{
return xlerror("bad argument type",arg);
}
Then replace all occurances of `xlerror("bad argument type",' with
`xlbadtype(' throughout the program (including xlisp.h).
***************************************
Add the file xlseq.c to your "makefile" in an appropriate manner.
***************************************
Add definition in xlisp.h:
#define xlgastrorsym() (testarg(symbolp(*xlargv) ? getpname(nextarg()) : typearg(stringp)))
Added external declaration in xlisp.h:
extern LVAL xlbadtype(); /* report "bad argument type" error */
***************************************
Add to init.lsp:
(unless (fboundp 'strcat) ; backwards compatibility
(defmacro strcat (&rest str) `(concatenate 'string ,@str)))
***************************************
In xlftab.c, add the following external declaration:
extern LVAL
xcoerce(), xconcatenate(), xelt(), xmap(), xsearch(), xpositionif(),
xcountif(),xfindif();
delete the declaration for xstrcat.
In funtab[], replace the definition for STRCAT with:
{ "CONCATENATE", S, xconcatenate }, /* 168 */
Replace NULL definitions at the end of the table with new definitions,
being sure to keep the table length constant.
{ "COUNT-IF", S, xcountif }, /* 287 */
{ "FIND-IF", S, xfindif }, /* 288 */
{ "COERCE", S, xcoerce }, /* 289 */
{ "ELT", S, xelt }, /* 290 */
{ "MAP", S, xmap }, /* 291 */
{ "POSITION-IF", S, xpositionif }, /* 292 */
{ "SEARCH", S, xsearch }, /* 293 */
*******************************
In file xlglob.c, add the following definition:
LVAL s_elt = NIL;
*******************************
In file xlinit.c, add the following external declaration:
extern LVAL s_elt;
in function xlsymbols(), in section "enter setf place specifiers", add
s_elt = xlenter("ELT");
*******************************
In file xlbfun.c, function xaref(), change
array = xlgavector();
to
array = xlgetarg();
Before the section titled "range check the index" add:
if (stringp(array)) { /* extension -- allow fetching chars from string*/
if (i < 0 || i >= getslength(array)-1)
xlerror("string index out of bounds",index);
return (cvchar(array->n_string[i]));
}
if (!vectorp(array)) xlbadtype(array); /* type must be array */
******************************
In xlcont.c, add the following declaration:
extern LVAL s_elt;
In function placeform(), replace the fun == s_aref code with:
xlsave1(arg1);
arg1 = evarg(&place); /* allow string argument */
arg2 = evmatch(FIXNUM,&place); i = getfixnum(arg2);
if (place) toomany(place);
if (stringp(arg1)) { /* extension for strings */
if (i < 0 || i >= getslength(arg1)-1)
xlerror("index out of range",arg2);
if (!charp(value))
xlerror("strings only contain characters",value);
arg1->n_string[i] = getchcode(value);
}
else if(vectorp(arg1)) {
if (i < 0 || i >= getsize(arg1))
xlerror("index out of range",arg2);
setelement(arg1,(int)i,value);
}
else xlbadtype(arg1);
xlpop();
Then add the following "case":
else if (fun == s_elt) {
xlsave1(arg1);
arg1 = evarg(&place);
arg2 = evmatch(FIXNUM,&place); i = getfixnum(arg2);
if (place) toomany(place);
if (listp(arg1)) {
for (; i > 0 && consp(arg1); --i)
arg1 = cdr(arg1);
if((!consp(arg1)) || i < 0)
xlerror("index out of range",arg2);
rplaca(arg1,value);
}
else if (ntype(arg1) == STRING) {
if (i < 0 || i >= getslength(arg1)-1)
xlerror("index out of range",arg2);
if (!charp(value))
xlerror("strings only contain characters",value);
arg1->n_string[i] = getchcode(value);
}
else if (ntype(arg1) == VECTOR) {
if (i < 0 || i >= getsize(arg1))
xlerror("index out of range",arg2);
setelement(arg1,(int)i,value);
}
else xlbadtype(arg1);
xlpop();
}
***************************
In xlstr.c, function changecase(), change
src = xlgastr